//
//  PersonOne.m
//  OCLearning
//
//  Created by Caldremch on 2018/5/27.
//  Copyright © 2018年 Caldremch. All rights reserved.
//

#import "PersonOne.h"

@implementation PersonOne

+ (instancetype)personWithName:(NSString *)name age:(int)age{
    
    PersonOne * person = [[PersonOne alloc] init];
    person.name = name;
    person.age = age;
    return person;
    
}

- (void)exercise:(myBlock)block{
    
    NSString * theName = @"Zhangsan";
    int age = 10;
    block(theName, age);
    
}

- (void)encodeWithCoder:(NSCoder *)coder
{
    ////在这个方法中要对类中声明的每个属性都要进行归档。
  
    [coder encodeObject:self.name forKey:@"name"];
    [coder encodeInteger:self.age forKey:@"age"];

}

- (instancetype)initWithCoder:(NSCoder *)coder
{

        ////通过查找键找出对应的属性值，而这个键值就是在归档时候设置的值。
        self.name = [coder decodeObjectForKey:@"name"];
    
         self.age = [coder decodeIntForKey:@"age"];

    return self;
}



@end
